package com.dries.portal.module.circle.controller;

import com.dries.common.api.CommonResult;
import com.dries.portal.module.circle.entity.CircleReply;
import com.dries.portal.module.circle.service.ICircleReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * 圈子动态回复表
 *
 * @author dries
 * @email samphsanie@gmail.com
 * @date 2020-08-26 14:27:42
 */
@RestController
@Api(tags = "动态评价API", value = "CircleReplyController")
@RequestMapping("circle/reply")
public class CircleReplyController {

    @Resource
    private ICircleReplyService circleReplyService;

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public CommonResult info(@PathVariable("id") Integer id) {
        CircleReply circleReply = circleReplyService.getById(id);
        return CommonResult.success();
    }

    /**
     * 保存
     */
    @ApiOperation("新增评论")
    @PostMapping("/save")
    public CommonResult save(@RequestBody CircleReply circleReply) {
        circleReplyService.save(circleReply);
        return CommonResult.success();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public CommonResult update(@RequestBody CircleReply circleReply) {
        circleReplyService.updateById(circleReply);

        return CommonResult.success();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public CommonResult delete(@RequestBody Integer[] ids) {
        circleReplyService.removeByIds(Arrays.asList(ids));

        return CommonResult.success();
    }

}
